Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Imports Microsoft.VisualBasic.PowerPacks
Imports MMUtil.clsGeneral
Imports Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6
Friend Class frmRes_Memo
	Inherits System.Windows.Forms.Form
	
	Dim SaveFlag As Short
	
	Private Sub cmdCancel_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCancel.ClickEvent
		gReturn = 0
		Me.Close()
	End Sub
	
	Private Sub cmdSave_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSave.ClickEvent
		Dim iLen As Short
		Dim iRet As Short
		
		iLen = Len(Trim(txtResMemo.Text))
		If iLen > 0 Then
			iRet = InStr(iLen - 4, Trim(txtResMemo.Text), Chr(10))
			If iRet > 0 Then
				gMemo = VB.Left(Trim(txtResMemo.Text), iRet - 2)
			Else
				gMemo = Trim(txtResMemo.Text)
			End If
		End If
		
		gReturn = 1
		Me.Close()
	End Sub
	
	Private Sub frmRes_Memo_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		gReturn = 0
		
		txtExamCode.Text = gCode
		txtExamCode_TextChanged(txtExamCode, New System.EventArgs())
		
	End Sub
	
	Private Sub frmRes_Memo_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		'Set frmResMemo = Nothing
	End Sub
	
	Private Sub lstPromise_DoubleClick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles lstPromise.DoubleClick
		Dim sMsg As String
		
		sMsg = VB6.GetItemString(lstPromise, lstPromise.SelectedIndex)
		
		If gHosInfo.HID = "114" Then
			sMsg = Trim(Mid(sMsg, 63))
			txtResMemo.Text = txtResMemo.Text & sMsg & CR
		Else
			sMsg = Trim(Mid(sMsg, 14))
			
			If txtResMemo.Text = "" Then
				txtResMemo.Text = sMsg & CR
			Else
				txtResMemo.Text = txtResMemo.Text & sMsg & CR
			End If
		End If
		
	End Sub
	
	'UPGRADE_WARNING: Event txtExamCode.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub txtExamCode_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtExamCode.TextChanged
		lstPromise.Items.Clear()
		
		'    If gHosInfo.HID = "114" Then
		'        SQL = "Select convert(char(8),ExamCode) + '  ' +  convert(char(4),SeqNo) + '   ' + convert(char(50),Comment) + '  ' + Remark From MEPromise " & CR & _
		''              "Where HID = '" & gHosInfo.HID & "' "
		'        If Trim(txtExamCode) <> "" Then
		'            SQL = SQL & CR & "  And ExamCode = '" & UCase(txtExamCode) & "' "
		'        End If
		'        SQL = SQL & CR & _
		''              "Order by ExamCode, SeqNo "
		'        db_select_List SQL, lstPromise
		'    Else
		SQL = "Select cast(ExamCode as char(10)) || ' ' ||  cast(TO_CHAR(SeqNo) as char(4)) || ' '  || Remark From MEPromise " & CR & "Where HID = '" & gHosInfo.HID & "' "
		If Trim(txtExamCode.Text) <> "" Then
			'SQL = SQL & CR & "  And ExamCode = '" & UCase(txtExamCode) & "' "
			SQL = SQL & CR & "  And ExamCode Like '" & UCase(txtExamCode.Text) & "%' "
		End If
		SQL = SQL & CR & "Order by ExamCode, SeqNo "
		db_select_List(SQL, lstPromise)
		'    End If
		
	End Sub
End Class